package com.health.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

@Configuration
@Slf4j
public class Knife4jConfig {

    /**
     * 通过knife4j生成接口文档
     */
    @Bean
    public Docket docket1() {
        ApiInfo apiInfo = new ApiInfoBuilder().title("传智健康接口文档")
                .version("1.0")
                .contact(new Contact("传智健康", "http://www.itheima.com", "itheima@itheima.com"))
                .description("传智健康接口文档")
                .build();

        Docket docket = new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo)
                .groupName("01.管理端接口文档")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.health.controller.manage"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }

    /**
     * 通过knife4j生成接口文档
     */
    @Bean
    public Docket docket2() {
        ApiInfo apiInfo = new ApiInfoBuilder().title("传智健康接口文档")
                .version("1.0")
                .contact(new Contact("传智健康", "http://www.itheima.com", "itheima@itheima.com"))
                .description("传智健康接口文档")
                .build();

        Docket docket = new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo)
                .groupName("02.移动端接口文档")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.health.controller.mobile"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }
}
